﻿using ViewMaker.Core.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using ViewMaker.Core;
using System.Collections.Generic;
using System.Windows.Controls;

namespace ViewMaker.Core.Tests
{
    [TestClass()]
    public class TabControlLayoutTypeTest
    {
        [TestMethod()]
        public void 標準的なTabControlのXAML生成()
        {
            var target = new TabControlViewControl { Width = 100, Item = new ViewLayoutItem { Name = "tb001", BindPath = "data" } };
            target.Item.Element = target;
            var txtItem1 = new ViewLayoutItem { Name = "txt001", Caption = "テキスト", BindPath = "textPath1" };
            txtItem1.Element = new TextBoxViewControl();
            target.Item.AddChild(txtItem1);
            var stItem2 = new ViewLayoutItem { Name = "st002", Caption = "スタックパネル" };
            stItem2.Element = new StackPanelViewControl();
            target.Item.AddChild(stItem2);
            var cvtem3 = new ViewLayoutItem { Name = "cv003", Caption = "キャンバス" };
            cvtem3.Element = new CanvasViewControl();
            target.Item.AddChild(cvtem3);

            var xaml = target.CreateXaml(TestHelper.CreateTestParent())[0];
            var actual = TestHelper.GetFrameworkElement<TabControl>(xaml);
            Assert.AreEqual("tb001", actual.Name);
            Assert.AreEqual("data", actual.GetBindingExpression(Canvas.DataContextProperty).ParentBinding.Path.Path);

            Assert.AreEqual("txt001", ((TextBox)((StackPanel)((TabItem)actual.Items[0]).Content).Children[1]).Name);
            Assert.AreEqual("st002", ((StackPanel)((TabItem)actual.Items[1]).Content).Name);
            Assert.AreEqual("cv003", ((Canvas)((TabItem)actual.Items[2]).Content).Name);
        }

        [TestMethod()]
        public void TabControlViewControlの編集画面が表示可能()
        {
            var target = new TabControlViewControl { Width = 100, Item = new ViewLayoutItem { Name = "tb001", BindPath = "data" } };
            var baml = ViewUtil.BuildContent(target);
            Assert.IsNotNull(baml);
        }

    }
}
